{
  File: nAppleTalk.p

 Version: 1.0a3

 Copyright Apple Computer, Inc. 1986, 1987
 All Rights Reserved

}

UNIT nAppleTalk;


INTERFACE

USES	{$U Memtypes.p	} Memtypes,
		{$U QuickDraw.p	} QuickDraw,
	 	{$U OSIntf.p	} OSIntf,
		{$U ToolIntf.p	} ToolIntf,
		{$U AppleTalk.p	} AppleTalk;


CONST
				{ AFPCall command codes }

AFPByteRangeLock	=	1;
AFPVolClose			=	2;
AFPDirClose			=	3;
AFPForkClose		=	4;
AFPCopyFile			=	5;
AFPDirCreate		=	6;
AFPFileCreate		=	7;
AFPDelete			=	8;
AFPEnumerate		=	9;
AFPFlush			=	10;
AFPForkFlush		=	11;
AFPGetDirParms		=	12;
AFPGetFileParms		=	13;
AFPGetForkParms		=	14;
AFPGetSInfo			=	15;
AFPGetSParms		=	16;
AFPGetVolParms		=	17;
AFPLogin			=	18;
AFPContLogin		=	19;
AFPLogout			=	20;
AFPMapID			=	21;
AFPMapName			=	22;
AFPMove				=	23;
AFPOpenVol			=	24;
AFPOpenDir			=	25;
AFPOpenFork			=	26;
AFPRead				=	27;
AFPRename			=	28;
AFPSetDirParms		=	29;
AFPSetFileParms		=	30;
AFPSetForkParms		=	31;
AFPSetVolParms		=	32;
AFPWrite			=	33;
AFPGetFlDrParms		=	34;
AFPSetFlDrParms		=	35;

AFPDTOpen			=	48;
AFPDTClose			=	49;
AFPGetIcon			=	51;
AFPGtIcnInfo		=	52;
AFPAddAPPL			=	53;
AFPRmvAPPL			=	54;
AFPGetAPPL			=	55;
AFPAddCmt			=	56;
AFPRmvCmt			=	57;
AFPGetCmt			=	58;

AFPAddIcon			=	192;		{ Special code for ASP Write commands }

				{ Error codes }

ASPBadVersNum		=	-1066;		{ Server cannot support this ASP version }
ASPBufTooSmall		=	-1067;		{ Buffer too small }
ASPNoMoreSess		=	-1068;		{ No more sessions on server }
ASPNoServers		=	-1069;		{ No servers at that address }
ASPParamErr			=	-1070;		{ Parameter error }
ASPServerBusy		=	-1071;		{ Server cannot open another session }
ASPSessClosed		=	-1072;		{ Session closed }
ASPSizeErr			=	-1073;		{ Command block too big }
ASPTooMany			=	-1074;		{ Too many clients (server error) }
ASPNoAck			=	-1075;		{ No ack on attention request (server err) }

AccessDenied        =	-5000;		{ $EC78 }
AuthContinue        =	-5001;		{ $EC77 }
BadUAM              =	-5002;		{ $EC76 }
BadVersNum          =	-5003;		{ $EC75 }
BitmapErr           =	-5004;		{ $EC74 }
CantMove            =	-5005;		{ $EC73 }
DenyConflict        =	-5006;		{ $EC72 }
DirNotEmpty         =	-5007;		{ $EC71 }
DiskFull            =	-5008;		{ $EC70 }
EOFError            =	-5009;		{ $EC6F }
FileBusy            =	-5010;		{ $EC6E }
FlatVol             =	-5011;		{ $EC6D }
ItemNotFound        =	-5012;		{ $EC6C }
LockErr             =	-5013;		{ $EC6B }
MiscErr             =	-5014;		{ $EC6A }
NoMoreLocks         =	-5015;		{ $EC69 }
NoServer            =	-5016;		{ $EC68 }
ObjectExists        =	-5017;		{ $EC67 }
ObjectNotFound      =	-5018;		{ $EC66 }
ParmErr             =	-5019;		{ $EC65 }
RangeNotLocked      =	-5020;		{ $EC64 }
RangeOverlap        =	-5021;		{ $EC63 }
SessClosed          =	-5022;		{ $EC62 }
UserNotAuth         =	-5023;		{ $EC61 }
CallNotSupported    =	-5024;		{ $EC60 }

				{ ASP miscellaneous }

XPPLoadedBit		=	5;				{ XPP bit in PortBUse }
XPPUnitNum			=	40;				{ Unit number for XPP (old ROMs) }

SCBMemSize			=	$C0; 			{ Size of memory for SCB }

XPPFlagClr			=	$00;			{ constants for AFPCommandBlock }
XPPFlagSet			=	$80;			{ StartEndFlag & NewLineFlag fields. }



TYPE

AFPCommandBlock = PACKED RECORD
	CmdByte:		Byte;
	StartEndFlag:	Byte;
	ForkRefNum:		INTEGER;
	RWOffset:		LONGINT;
	ReqCount:		LONGINT;
	NewLineFlag:	Byte;
	NewLineChar:	CHAR;
END;    { AFPCommandBlock }

XPPPrmBlkType = (XPPPrmBlk, ASPSizeBlk, ASPAbortPrm);
XPPSubPrmType = (ASPOpenPrm, ASPSubPrm);
XPPEndPrmType = (AFPLoginPrm, ASPEndPrm);

XPPParamBlock = PACKED RECORD
	qLink:			QElemPtr;			{ next queue entry }
	qType:			INTEGER;			{ queue type }
	ioTrap:			INTEGER;			{ routine trap }
	ioCmdAddr:		Ptr;				{ routine address }
	ioCompletion:	ProcPtr;			{ completion routine }
	ioResult:		OSErr;				{ result code }
	CmdResult:		LONGINT;			{ Command result (ATP user bytes) [long] }
	ioVRefNum:		INTEGER;			{ volume reference or drive number }
	ioRefNum:		INTEGER;			{ driver reference number }
	csCode:			INTEGER;			{ Call command code }
	CASE XPPPrmBlkType OF
	  ASPAbortPrm:
		(AbortSCBPtr:	Ptr);			{ SCB pointer for AbortOS [long] }
	  ASPSizeBlk:
		(ASPMaxCmdSize:	INTEGER;		{ For SPGetParms [word] }
		ASPQuantumSize:	INTEGER;		{ For SPGetParms [word] }
		NumSesss:		INTEGER);		{ For SPGetParms [word] }
	  XPPPrmBlk:
		(SessRefnum:	INTEGER;		{ Offset to session refnum [word] }
		ASPTimeout:		Byte;			{ Timeout for ATP [byte] }
		ASPRetry:		Byte;			{ Retry count for ATP [byte] }
		CASE XPPSubPrmType OF
		  ASPOpenPrm:
			(ServerAddr:	AddrBlock;	{ Server address block [longword] }
			SCBPointer:		Ptr;		{ SCB pointer [longword] }
			AttnRoutine:	Ptr);		{ Attention routine pointer [long] }
		  ASPSubPrm:
			(CBSize:		INTEGER;	{ Command block size [word] }
			CBPtr:			Ptr;		{ Command block pointer [long] }
			RBSize:			INTEGER;	{ Reply buffer size [word] }
			RBPtr:			Ptr;		{ Reply buffer pointer [long] }
			CASE XPPEndPrmType OF
			  AFPLoginPrm:
				(AFPAddrBlock:	AddrBlock;	{ Address block in AFP login [long] }
				AFPSCBPtr:		Ptr;		{ SCB pointer in AFP login [long] }
				AFPAttnRoutine:	Ptr);		{ Attn routine pointer in AFP login }
			  ASPEndPrm:
				(WDSize:		INTEGER;	{ Write data size [word] }
				WDPtr:			Ptr;		{ Write data pointer [long] }
				CCBStart: 		ARRAY[0..295] OF Byte)));	{ CCB memory allocated for driver }
				{AFPWrite max size(CCB) = 296; all other calls = 150}
END;    { XPPParamBlock }

XPPParmBlkPtr = ^XPPParamBlock;  		{ Pointer to an XPP record }



FUNCTION OpenXPP(VAR XPPRefnum: INTEGER): OSErr;

FUNCTION ASPOpenSession(xParamBlock: XPPParmBlkPtr; async: BOOLEAN): OSErr;

FUNCTION ASPCloseSession(xParamBlock: XPPParmBlkPtr; async: BOOLEAN): OSErr;

FUNCTION ASPAbortOS(xParamBlock: XPPParmBlkPtr; async: BOOLEAN): OSErr;

FUNCTION ASPGetParms(xParamBlock: XPPParmBlkPtr; async: BOOLEAN): OSErr;

FUNCTION ASPCloseAll(xParamBlock: XPPParmBlkPtr; async: BOOLEAN): OSErr;

FUNCTION ASPUserWrite(xParamBlock: XPPParmBlkPtr; async: BOOLEAN): OSErr;

FUNCTION ASPUserCommand(xParamBlock: XPPParmBlkPtr; async: BOOLEAN): OSErr;

FUNCTION ASPGetStatus(xParamBlock: XPPParmBlkPtr; async: BOOLEAN): OSErr;

FUNCTION AFPCommand(xParamBlock: XPPParmBlkPtr; async: BOOLEAN): OSErr;


END.
